/**
 * 连接数据库
 */
package com.xiaomuwu.android.logic.dao

import android.util.Log
import java.sql.Connection
import java.sql.DriverManager
import kotlin.concurrent.thread

object DatabaseConnection {
    /**
     * 数据库连接函数
     */
    fun connectDatabase(): Connection? {
        val url="jdbc:jtds:sqlserver://10.0.2.2:1433;DatabaseName=SharedResources"
        val userName="sa"   // 登录名
        val password="1234" // 密码
        return try {
//            thread {
                val connection= DriverManager.getConnection(url,userName,password)
                Log.d("DatabaseConnection","数据库连接成功")
                connection
//            }
        }catch (e:Exception){
            e.printStackTrace()
            Log.d("DatabaseConnection","数据库连接失败")
            null
        }
    }
}